import {myNewTaskForStudent, errorLog} from '../api/task.js'
import {mapState, mapMutations,mapGetters} from 'vuex'
import config from './config.js'
// const url = config.url
const url = 'https://zhiyue.insyte.cn'
export default {
	data(){
		return {
			debug: false
		}
	},
	computed:{

	},
	filters:{
		remoteImgSource(str){
			if(typeof str === 'string'){
				return url + str
			}else{
				return ''
			}
		},
		bookFaceImg(id){
			if(typeof id !== 'number'){
				return '/static/img/book/bookface.png'
			}else{
				return `${url}/FileApi/File/Download?fileid=${id}`
			}
		},
		separateTime(str){
			if(typeof str === 'string'){
				return str.replace('T', ' ').replace(/\..*$/, '')
			}
			return ''
		},
		sliceData(str){
			if(typeof str === 'string'){
				return str.replace(/T.*$/, '')
			}
			return ''
		},
		decode(str){
			if(typeof str === 'string'){
				// str = str.replace(/%/g, '%25')
				try{
					return decodeURIComponent(str)
				}catch(err){
					console.log(err)
				}
			}else{
				return ''
			}
		}
	},
	methods:{
		...mapMutations(['setQuizetask', 'setExamtask', 'setReviewtask', 'setWritingtask','reduceQuizetask', 'reduceExamtask', 'reduceReviewtask', 'reduceWritingtask']),
		setTitle(title){
			document.getElementsByTagName('title')[0].innerText = title
		},
		//错题上报日志
		questionErrorLog(logData){
			
			console.log(logData)
			var data = {
				type: 1,
				title: logData.msg,
				content: JSON.stringify(logData),
			}
			// errorLog(data)
			uni.showModal({
				title: '警告',
				content: '题目下载失败',
				showCancel: false,
				success: (res)=>{
					if(res.confirm){
						uni.navigateBack()
					}
				}
			})
		}
	},
	onShareAppMessage(){
		
	}
}